module dgl.BoundingSphere;

import dgl.graphics.ContainmentType;
import dgl.Vector3;

struct BoundingSphere
{
	public Vector3 center;
	
	public float radius;
	
	public static BoundingSphere opCall( Vector3 center, float radius )
	{
		BoundingSphere ret;
		ret.center = center;
		ret.radius = radius;
		return ret;
	}
	
	public ContainmentType contains( Vector3 point )
	{
		if( Vector3.distanceSquared( point, center ) >= radius * radius )
		{
			return ContainmentType.Disjoint;
		}
		return ContainmentType.Contains;
	}
	
	public bool intersects( BoundingSphere sphere )
	{
		float num3 = Vector3.distanceSquared( this.center, sphere.center );
		float num = sphere.radius;
		if( ( ( ( radius * radius ) + ( ( 2f * radius ) * num ) ) + ( num * num ) ) <= num3 )
		{
			return false;
		}
		return true;
	}
}